package com.itic.mobile.upload;

import java.io.File;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.model.PutObjectResult;
import com.qcloud.cos.region.Region;

public class TencentOSSClient {	
	private static final String  BasicKey1= "AKID2sTQ9dgqeDXbS74idLo0wc1A2dx1eWyA";
	private static final String  BasicKey2= "5wXsxlJabLp43mFTR9cqoWy94j8G9pFQ";
	private static final String Region ="ap-beijing";
	public static final String BucketName = "uhuijia-1254600872";
	public static final String COSUrl ="https://uhuijia-1254600872.cos.ap-beijing.myqcloud.com/";
	
	private static COSClient cosclient = new COSClient(new BasicCOSCredentials(BasicKey1,BasicKey2), new ClientConfig(new Region(Region)));
	
	private TencentOSSClient(){}
	
    public static COSClient getInstance(){
        return cosclient;
    }
    
    public static String uploadFile(String key ,File localFile) {
    	PutObjectRequest putObjectRequest = new PutObjectRequest(TencentOSSClient.BucketName, key, localFile);
	    PutObjectResult result =  cosclient.putObject(putObjectRequest);
	    return result.getETag();
    }
}
